/**
 * 配置相关接口的mock数据
 */

// 模拟币种列表数据
const iconList = {
  name: '支持的币种',
  chains: [
    {
      id: 1,
      name: 'Ethereum',
      url: 'https://mainnet.infura.io/v3/your-api-key',
      iconType: 'ETH',
      icon: '/images/icons/eth.png',
      decimal: 18,
      precision: 6,
      contact: '0x0000000000000000000000000000000000000000',
      toAddress: '0xabcdef1234567890abcdef1234567890abcdef12'
    },
    {
      id: 2,
      name: 'Tron',
      url: 'https://api.trongrid.io',
      iconType: 'USDT',
      icon: '/images/icons/usdt.png',
      decimal: 6,
      precision: 2,
      contact: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
      toAddress: 'TXk8rQSAvPvBBNtqSoY6nKzVzSZkQhYYN3'
    },
    {
      id: 3,
      name: 'Binance Smart Chain',
      url: 'https://bsc-dataseed.binance.org',
      iconType: 'BNB',
      icon: '/images/icons/bnb.png',
      decimal: 18,
      precision: 6,
      contact: '0x0000000000000000000000000000000000000000',
      toAddress: '0xabcdef1234567890abcdef1234567890abcdef12'
    }
  ]
}

// 模拟区域数据列表
const areaList = [
  {
    id: 1,
    areaName: '北京市',
    parentId: 0
  },
  {
    id: 2,
    areaName: '上海市',
    parentId: 0
  },
  {
    id: 3,
    areaName: '广东省',
    parentId: 0
  },
  {
    id: 4,
    areaName: '深圳市',
    parentId: 3
  },
  {
    id: 5,
    areaName: '广州市',
    parentId: 3
  },
  {
    id: 6,
    areaName: '南山区',
    parentId: 4
  },
  {
    id: 7,
    areaName: '福田区',
    parentId: 4
  }
]

// 模拟字典列表数据
const dicList = [
  {
    groupKey: 'NATION',
    key: 'HAN',
    value: '汉族',
    extra: ''
  },
  {
    groupKey: 'NATION',
    key: 'MAN',
    value: '满族',
    extra: ''
  },
  {
    groupKey: 'RELATION',
    key: 'FATHER',
    value: '父亲',
    extra: ''
  },
  {
    groupKey: 'RELATION',
    key: 'MOTHER',
    value: '母亲',
    extra: ''
  },
  {
    groupKey: 'TIPS',
    key: 'NOTICE',
    value: '系统公告',
    extra: '这是一条系统公告'
  }
]

/**
 * 获取币种列表
 * @returns {Object} 币种列表数据
 */
export function getIconList() {
  return {
    code: 0,
    message: '获取币种列表成功',
    data: iconList
  }
}

/**
 * 获取区域数据列表
 * @param {Object} params 查询参数
 * @returns {Object} 区域数据列表
 */
export function getAreaList(params) {
  const { parentId = 0, all = false } = params
  
  let result = []
  if (all) {
    result = areaList
  } else {
    result = areaList.filter(item => item.parentId === parseInt(parentId))
  }
  
  return {
    code: 0,
    message: '获取区域数据成功',
    data: result
  }
}

/**
 * 获取字典列表
 * @param {Object} params 查询参数
 * @returns {Object} 字典列表数据
 */
export function getDicList(params) {
  const { key = '', page = 1, size = 10 } = params
  
  let filteredList = [...dicList]
  if (key) {
    filteredList = filteredList.filter(item => item.groupKey === key)
  }
  
  const total = filteredList.length
  const list = filteredList.slice((page - 1) * size, page * size)
  
  return {
    code: 0,
    message: '获取字典列表成功',
    data: {
      list,
      total,
      page: parseInt(page),
      size: parseInt(size)
    }
  }
}